#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
using namespace std;
int n,l,r,ans;
int main () {
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	scanf("%d%d%d",&n,&l,&r);
	ans=min(n*(l/n)+(n-1),r);
	printf("%d\n",ans%n);
	return 0;
}
